package com.zc.utils;

public class RandCodeUtil {

	public static int getRandNum(int min, int max) {
		int randNum = min + (int) (Math.random() * ((max - min) + 1));
		return randNum;
	}

	public static String randCode(int num) {

		String letters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
		int index;
		String ret = "";
		for (int i = 0; i < num; i++) {
			index = getRandNum(0, 10000) % 62;
			ret = ret + letters.charAt(index);
		}
		return ret;
	}

	public static String getOrderId() {
		String orderId;
		long time = System.currentTimeMillis();
		orderId = "" + time + randCode(6);
		return orderId;
	}

}
